#ifndef MYSERIALPORT_H
#define MYSERIALPORT_H

#include <QObject>
#include <QSerialPort>

class MySerialport : public QObject
{
    Q_OBJECT
public:

    static MySerialport* getObjCom1();
    static MySerialport* getObjCom2();


    qint32 getBaudRate(){return mCom->baudRate();}
    QString getBaudRateStr();
    QSerialPort::DataBits getDataBits(){return mCom->dataBits();}
    QString getDataBitsStr();
    QString getParityStr();
    QSerialPort::Parity getParity(){return mCom->parity();}
    QString getFlowCtrlStr();
    QSerialPort::FlowControl getFlowCtrl() {return mCom->flowControl();}
    QSerialPort::StopBits getStopBits() {return mCom->stopBits();}
    QString getStopBitsStr();
    QString getSettingGroupName() {return mSettingGroupName;}

    static QStringList getBaudRateList();
    static QStringList getDataBitsList();
    static QStringList getParityList();
    static QStringList getFlowCtrlList();
    static QStringList getStopBitsList();
    void initComSetting(int,int,int,int,int);
signals:

public slots:
    void onRead();

private:
    explicit MySerialport(const QString& name,QObject *parent = 0);
    static MySerialport* mSp1;
    static MySerialport* mSp2;
    QString mSettingGroupName;
    QSerialPort* mCom;

    static QStringList mBaudList;
    static QStringList mDataBitsList;
    static QStringList mParityList;
    static QStringList mFlowCtrlList;
    static QStringList mStopList;
    void __setBraudRate(int);
    void __setDataBits(int);
    void __setStopBits(int);
    void __setFlowCtrl(int);
    void __setParity(int);
};

#endif // MYSERIALPORT_H
